#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    QPushButton* btn = new QPushButton("按钮", this);
    btn->move(100,122);
    resize(800,600);

//    connect(this, &Widget::MySignal_1, this, &Widget::MySlot);
    connect(this, SIGNAL(MySignal_1()), this, SLOT(MySlot()));
    connect(this, &Widget::MySignal_2, this, &Widget::MySlot);
    connect(btn, &QPushButton::clicked, this, &Widget::MySlot);
    disconnect(btn, &QPushButton::clicked, this, &Widget::MySlot);
    connect(btn, &QPushButton::clicked, this, &Widget::MySlot);
    EmitSignal(); //发射信号
}

Widget::~Widget()
{
    delete ui;
}

void Widget::MySlot()
{
    qDebug() << "MySlot";
}

void Widget::EmitSignal()
{
    emit MySignal_1();
    emit MySignal_2();
}
